package ee.ut.aa.neuraltic.main;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import ee.ut.aa.neuraltic.genetic.Brain;
import ee.ut.aa.neuraltic.logic.Competition;
import ee.ut.aa.neuraltic.logic.GeneticTrainer;
import ee.ut.aa.neuraltic.logic.PopulationStats;
import ee.ut.aa.neuraltic.model.Board;
import ee.ut.aa.neuraltic.model.RandomPlayer;
import ee.ut.aa.neuraltic.model.TicBoard;
import ee.ut.aa.neuraltic.neural.Network;
import ee.ut.aa.neuraltic.neural.TicNetwork;

public class Main {

	private static Logger log = Logger.getLogger( Main.class );

	public static void main( String[] args ) throws FileNotFoundException, IOException {

		 Properties logProperties = new Properties();

		 // load our log4j properties / configuration file
		 logProperties.load(new FileInputStream("etc/log4j.properties"));
		 PropertyConfigurator.configure(logProperties);

		log.info( "Hello world!" );

//		Board board = new TicBoard();
//		RandomPlayer one = new RandomPlayer( 1 );
//		RandomPlayer two = new RandomPlayer( -1 );
//
//		Competition comp = new Competition();
//
//		comp.competition( one, two, board );
//
//		log.debug( board );
//
//		Brain brain = new Brain();
//		brain.initPopulation();
//		brain.iteration();
//		
//		log.info( "testing input-output" );
//
//		double[] input = { 0.0, -1.0, 0.0, 1.0, 0.0, 1.0, -1.0, 0.0, 0.0 };
//
//		Network network = new TicNetwork();
//		network.getInput().feedInput( input );
//		network.getInput().initFeedForward();
//		network.getOutput().retreiveOutput();
//		
//		log.debug( network );
//		PopulationStats.logNetwork( network );
//		
//		log.info( "testing trainer" );
		
		GeneticTrainer trainer = new GeneticTrainer();
		
		trainer.startTraining( 100 );
		
	}
}
